package niuke;

import java.util.Scanner;

public class 回文序列 {

    static int length;
    static int[] a;
    static int count = 0;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        length = scanner.nextInt();
        a = new int[length];
        for(int i=0;i<length;i++){
            a[i] = scanner.nextInt();
        }
        f(0,length-1);
        System.out.println(count);
    }

    public static void f(int left,int right){
        while (left<right){
            if(a[left] < a[right]){
                a[left+1] = a[left] + a[left+1];
                left++;
                count++;
            }
            else if(a[left] > a[right]){
                a[right-1] = a[right] + a[right-1];
                right--;
                count++;
            }
            else {
                left++;
                right--;
            }
        }
    }
}
